home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 037a / phello.zip / HELLOAPI.PAS < prev    next >
Pascal/Delphi Source File  |  1991-04-25  |  3KB  |  112 lines

  1. {************************************************}
  2. {                                                }
  3. {   Turbo Pascal for Windows                     }
  4. {   Generic API Hello Windows application        }
  5. {   Copyright (c) 1991 by Borland International  }
  6. {                                                }
  7. {************************************************}
  8.  
  9. program HelloAPI;
  10.  
  11. {$R GENERIC}
  12.  
  13. uses WinTypes, WinProcs;
  14.  
  15. const
  16.   AppName = 'Generic';
  17.  
  18. const
  19.   idm_About = 100;
  20.  
  21. function About(Dialog: HWnd; Message, WParam: Word;
  22.   LParam: Longint): Bool; export;
  23. begin
  24.   About := True;
  25.   case Message of
  26.     wm_InitDialog:
  27.       Exit;
  28.     wm_Command:
  29.       if (WParam = id_Ok) or (WParam = id_Cancel) then
  30.       begin
  31.         EndDialog(Dialog, 1);
  32.         Exit;
  33.       end;
  34.   end;
  35.   About := False;
  36. end;
  37.  
  38. function WindowProc(Window: HWnd; Message, WParam: Word;
  39.   LParam: Longint): Longint; export;
  40. var
  41.   AboutProc: TFarProc;
  42. begin
  43.   WindowProc := 0;
  44.   case Message of
  45.     wm_Command:
  46.       if WParam = idm_About then
  47.       begin
  48.         AboutProc := MakeProcInstance(@About, HInstance);
  49.         DialogBox(HInstance, 'AboutBox', Window, AboutProc);
  50.         FreeProcInstance(AboutProc);
  51.         Exit;
  52.       end;
  53.     wm_Destroy:
  54.       begin
  55.         PostQuitMessage(0);
  56.         Exit;
  57.       end;
  58.   end;
  59.   WindowProc := DefWindowProc(Window, Message, WParam, LParam);
  60. end;
  61.  
  62. procedure WinMain;
  63. var
  64.   Window: HWnd;
  65.   Message: TMsg;
  66. const
  67.   WindowClass: TWndClass = (
  68.     style: 0;
  69.     lpfnWndProc: @WindowProc;
  70.     cbClsExtra: 0;
  71.     cbWndExtra: 0;
  72.     hInstance: 0;
  73.     hIcon: 0;
  74.     hCursor: 0;
  75.     hbrBackground: 0;
  76.     lpszMenuName: AppName;
  77.     lpszClassName: AppName);
  78. begin
  79.   if HPrevInst = 0 then
  80.   begin
  81.     WindowClass.hInstance := HInstance;
  82.     WindowClass.hIcon := LoadIcon(0, idi_Application);
  83.     WindowClass.hCursor := LoadCursor(0, idc_Arrow);
  84.     WindowClass.hbrBackground := GetStockObject(white_Brush);
  85.     if not RegisterClass(WindowClass) then Halt(255);
  86.   end;
  87.   Window := CreateWindow(
  88.     AppName,
  89.     'Hello API',
  90.     ws_OverlappedWindow,
  91.     cw_UseDefault,
  92.     cw_UseDefault,
  93.     cw_UseDefault,
  94.     cw_UseDefault,
  95.     0,
  96.     0,
  97.     HInstance,
  98.     nil);
  99.   ShowWindow(Window, CmdShow);
  100.   UpdateWindow(Window);
  101.   while GetMessage(Message, 0, 0, 0) do
  102.   begin
  103.     TranslateMessage(Message);
  104.     DispatchMessage(Message);
  105.   end;
  106.   Halt(Message.wParam);
  107. end;
  108.  
  109. begin
  110.   WinMain;
  111. end.
  112.